#!/usr/bin/env python
import logging
import os
import sys
from simple_server import run

# 配置日志
logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    handlers=[
        logging.StreamHandler()
    ]
)
logger = logging.getLogger(__name__)

if __name__ == "__main__":
    # 设置环境变量
    os.environ.setdefault("AUDIT_HOST", "0.0.0.0")
    os.environ.setdefault("AUDIT_PORT", "8090")
    
    logger.info("启动自动审核服务...")
    
    # 获取主机和端口配置
    host = os.environ.get("AUDIT_HOST", "0.0.0.0")
    port = int(os.environ.get("AUDIT_PORT", "8090"))
    
    # 启动服务
    try:
        run(host=host, port=port)
    except KeyboardInterrupt:
        logger.info("服务已停止")
    except Exception as e:
        logger.error(f"服务启动失败: {str(e)}")
        sys.exit(1) 